package com.jh3502.vivo.function.account;

import android.support.annotation.NonNull;

import com.jh3502.vivo.base.BaseCallback;
import com.jh3502.vivo.base.BaseJson;
import com.jh3502.vivo.base.BasePresenter;
import com.jh3502.vivo.base.BaseView;

import java.util.Map;

/**
 * @author harisucici
 * @date 2017/6/19
 */

public class AccountPresenter extends BasePresenter<AccountPresenter.AccountView> {
    AccountModel mAccountModel;

    AccountView mAccountView;

    public void setAccountView(AccountView mAccountView) {
        this.mAccountView = mAccountView;
    }

    public void toFindaccount(Map<String, Object> body) {
        mAccountView.showLoadingDialog();
        if (mAccountModel == null) {
            mAccountModel = new AccountModel(mAccountView.getActContext());
        }

        mAccountModel.findaccount(body, new BaseCallback(mAccountView) {
            @Override
            public void responseSuccess(@NonNull BaseJson baseJson) {
                mAccountView.findaccountSuccess(baseJson.getObj().toString());
            }
        });
    }

    public void toModifyaccount(Map<String, Object> body) {
        mAccountView.showLoadingDialog();
        if (mAccountModel == null) {
            mAccountModel = new AccountModel(mAccountView.getActContext());
        }

        mAccountModel.modifyaccount(body, new BaseCallback(mAccountView) {
            @Override
            public void responseSuccess(@NonNull BaseJson baseJson) {
                mAccountView.modifyaccountSuccess();
            }
        });
    }


    @Override
    public void cancelCall() {

    }

    public interface AccountView extends BaseView {


        void modifyaccountSuccess();

        void findaccountSuccess(String s);
    }
}
